/*   1:    */ package org.jetbrains.jps.model.serialization.java.compiler;
/*   2:    */ 
/*   3:    */

import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import org.jdom.Element;
import org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile;

import java.io.File;
import java.util.*;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */
/*  15:    */
/*  16:    */
/*  17:    */ 
/*  18:    */ public class AnnotationProcessorProfileSerializer
/*  19:    */ {
/*  20: 30 */   private static final Comparator<String> a = new Comparator()
/*  21:    */   {
/*  22:    */     public int compare(String paramAnonymousString1, String paramAnonymousString2)
/*  23:    */     {
/*  24: 33 */       return paramAnonymousString1.compareToIgnoreCase(paramAnonymousString2);
/*  25:    */     }
/*  26:    */   };
/*  27:    */   private static final String b = "entry";
/*  28:    */   private static final String c = "name";
/*  29:    */   private static final String d = "value";
/*  30:    */   private static final String e = "enabled";
/*  31:    */   private static final String f = "option";
/*  32:    */   private static final String g = "module";
/*  33:    */   
/*  34:    */   public static void readExternal(ProcessorConfigProfile paramProcessorConfigProfile, Element paramElement)
/*  35:    */   {
/*  36: 44 */     paramProcessorConfigProfile.setName(paramElement.getAttributeValue("name", ""));
/*  37: 45 */     paramProcessorConfigProfile.setEnabled(Boolean.valueOf(paramElement.getAttributeValue("enabled", "false")).booleanValue());
/*  38:    */     
/*  39: 47 */     Element localElement1 = paramElement.getChild("sourceOutputDir");
/*  40: 48 */     paramProcessorConfigProfile.setGeneratedSourcesDirectoryName(localElement1 != null ? localElement1.getAttributeValue("name") : null, false);
/*  41:    */     
/*  42: 50 */     Element localElement2 = paramElement.getChild("sourceTestOutputDir");
/*  43: 51 */     paramProcessorConfigProfile.setGeneratedSourcesDirectoryName(localElement2 != null ? localElement2.getAttributeValue("name") : null, true);
/*  44:    */     
/*  45: 53 */     Element localElement3 = paramElement.getChild("outputRelativeToContentRoot");
/*  46: 54 */     if (localElement3 != null) {
/*  47: 55 */       paramProcessorConfigProfile.setOutputRelativeToContentRoot(Boolean.parseBoolean(localElement3.getAttributeValue("value")));
/*  48:    */     }
/*  49: 58 */     paramProcessorConfigProfile.clearProcessorOptions();
/*  50: 59 */     for (Object localObject1 = paramElement.getChildren("option").iterator(); ((Iterator)localObject1).hasNext();)
/*  51:    */     {
/*  52: 59 */       localObject2 = (Element)((Iterator)localObject1).next();
/*  53: 60 */       localObject3 = (Element)localObject2;
/*  54: 61 */       localObject4 = ((Element)localObject3).getAttributeValue("name");
/*  55: 62 */       str = ((Element)localObject3).getAttributeValue("value");
/*  56: 63 */       if ((!StringUtil.isEmptyOrSpaces((String)localObject4)) && (str != null)) {
/*  57: 64 */         paramProcessorConfigProfile.setOption((String)localObject4, str);
/*  58:    */       }
/*  59:    */     }
/*  60:    */     Object localObject3;
/*  61:    */     Object localObject4;
/*  62:    */     String str;
/*  63: 68 */     paramProcessorConfigProfile.clearProcessors();
/*  64: 69 */     for (localObject1 = paramElement.getChildren("processor").iterator(); ((Iterator)localObject1).hasNext();)
/*  65:    */     {
/*  66: 69 */       localObject2 = (Element)((Iterator)localObject1).next();
/*  67: 70 */       localObject3 = ((Element)localObject2).getAttributeValue("name");
/*  68: 71 */       if (!StringUtil.isEmptyOrSpaces((String)localObject3)) {
/*  69: 72 */         paramProcessorConfigProfile.addProcessor((String)localObject3);
/*  70:    */       }
/*  71:    */     }
/*  72: 76 */     localObject1 = paramElement.getChild("processorPath");
/*  73: 77 */     if (localObject1 != null)
/*  74:    */     {
/*  75: 78 */       paramProcessorConfigProfile.setObtainProcessorsFromClasspath(Boolean.parseBoolean(((Element)localObject1).getAttributeValue("useClasspath", "true")));
/*  76: 79 */       localObject2 = new StringBuilder();
/*  77: 80 */       for (localObject3 = ((Element)localObject1).getChildren("entry").iterator(); ((Iterator)localObject3).hasNext();)
/*  78:    */       {
/*  79: 80 */         localObject4 = (Element)((Iterator)localObject3).next();
/*  80: 81 */         str = ((Element)localObject4).getAttributeValue("name");
/*  81: 82 */         if (!StringUtil.isEmptyOrSpaces(str))
/*  82:    */         {
/*  83: 83 */           if (((StringBuilder)localObject2).length() > 0) {
/*  84: 84 */             ((StringBuilder)localObject2).append(File.pathSeparator);
/*  85:    */           }
/*  86: 86 */           ((StringBuilder)localObject2).append(FileUtil.toSystemDependentName(str));
/*  87:    */         }
/*  88:    */       }
/*  89: 89 */       paramProcessorConfigProfile.setProcessorPath(((StringBuilder)localObject2).toString());
/*  90:    */     }
/*  91: 92 */     paramProcessorConfigProfile.clearModuleNames();
/*  92: 93 */     for (Object localObject2 = paramElement.getChildren("module").iterator(); ((Iterator)localObject2).hasNext();)
/*  93:    */     {
/*  94: 93 */       localObject3 = (Element)((Iterator)localObject2).next();
/*  95: 94 */       localObject4 = ((Element)localObject3).getAttributeValue("name");
/*  96: 95 */       if (!StringUtil.isEmptyOrSpaces((String)localObject4)) {
/*  97: 96 */         paramProcessorConfigProfile.addModuleName((String)localObject4);
/*  98:    */       }
/*  99:    */     }
/* 100:    */   }
/* 101:    */   
/* 102:    */   public static void writeExternal(ProcessorConfigProfile paramProcessorConfigProfile, Element paramElement)
/* 103:    */   {
/* 104:102 */     paramElement.setAttribute("name", paramProcessorConfigProfile.getName());
/* 105:103 */     paramElement.setAttribute("enabled", Boolean.toString(paramProcessorConfigProfile.isEnabled()));
/* 106:    */     
/* 107:105 */     String str1 = paramProcessorConfigProfile.getGeneratedSourcesDirectoryName(false);
/* 108:106 */     if (!StringUtil.equals("generated", str1)) {
/* 109:107 */       a(paramElement, "sourceOutputDir").setAttribute("name", str1);
/* 110:    */     }
/* 111:109 */     String str2 = paramProcessorConfigProfile.getGeneratedSourcesDirectoryName(true);
/* 112:110 */     if (!StringUtil.equals("generated_tests", str2)) {
/* 113:111 */       a(paramElement, "sourceTestOutputDir").setAttribute("name", str2);
/* 114:    */     }
/* 115:114 */     if (paramProcessorConfigProfile.isOutputRelativeToContentRoot()) {
/* 116:115 */       a(paramElement, "outputRelativeToContentRoot").setAttribute("value", "true");
/* 117:    */     }
/* 118:118 */     Map localMap = paramProcessorConfigProfile.getProcessorOptions();
/* 119:119 */     if (!localMap.isEmpty())
/* 120:    */     {
/* 121:120 */       localObject1 = new ArrayList(localMap.keySet());
/* 122:121 */       Collections.sort((List)localObject1, a);
/* 123:122 */       for (localObject2 = ((List)localObject1).iterator(); ((Iterator)localObject2).hasNext();)
/* 124:    */       {
/* 125:122 */         localObject3 = (String)((Iterator)localObject2).next();
/* 126:123 */         a(paramElement, "option").setAttribute("name", (String)localObject3).setAttribute("value", (String)localMap.get(localObject3));
/* 127:    */       }
/* 128:    */     }
/* 129:127 */     Object localObject1 = paramProcessorConfigProfile.getProcessors();
/* 130:128 */     if (!((Set)localObject1).isEmpty())
/* 131:    */     {
/* 132:129 */       localObject2 = new ArrayList((Collection)localObject1);
/* 133:130 */       Collections.sort((List)localObject2, a);
/* 134:131 */       for (localObject3 = ((List)localObject2).iterator(); ((Iterator)localObject3).hasNext();)
/* 135:    */       {
/* 136:131 */         localObject4 = (String)((Iterator)localObject3).next();
/* 137:132 */         a(paramElement, "processor").setAttribute("name", (String)localObject4);
/* 138:    */       }
/* 139:    */     }
/* 140:136 */     Object localObject2 = a(paramElement, "processorPath").setAttribute("useClasspath", Boolean.toString(paramProcessorConfigProfile.isObtainProcessorsFromClasspath()));
/* 141:    */     
/* 142:138 */     Object localObject3 = paramProcessorConfigProfile.getProcessorPath();
/* 143:    */     Object localObject5;
/* 144:139 */     if (!StringUtil.isEmpty((String)localObject3))
/* 145:    */     {
/* 146:140 */       localObject4 = new StringTokenizer((String)localObject3, File.pathSeparator, false);
/* 147:141 */       while (((StringTokenizer)localObject4).hasMoreTokens())
/* 148:    */       {
/* 149:142 */         localObject5 = ((StringTokenizer)localObject4).nextToken();
/* 150:143 */         a((Element)localObject2, "entry").setAttribute("name", FileUtil.toSystemIndependentName((String)localObject5));
/* 151:    */       }
/* 152:    */     }
/* 153:147 */     Object localObject4 = paramProcessorConfigProfile.getModuleNames();
/* 154:148 */     if (!((Set)localObject4).isEmpty())
/* 155:    */     {
/* 156:149 */       localObject5 = new ArrayList((Collection)localObject4);
/* 157:150 */       Collections.sort((List)localObject5, a);
/* 158:151 */       for (String str3 : (List)localObject5) {
/* 159:152 */         a(paramElement, "module").setAttribute("name", str3);
/* 160:    */       }
/* 161:    */     }
/* 162:    */   }
/* 163:    */   
/* 164:    */   private static Element a(Element paramElement, String paramString)
/* 165:    */   {
/* 166:158 */     Element localElement = new Element(paramString);
/* 167:159 */     paramElement.addContent(localElement);
/* 168:160 */     return localElement;
/* 169:    */   }
/* 170:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.jps.model.serialization.java.compiler.AnnotationProcessorProfileSerializer

 * JD-Core Version:    0.7.0.1

 */